package com.yswl.pri.home.vedio.utils;



import com.yswl.pri.Constant;

import java.util.ArrayList;
import java.util.List;

import yswl.com.klibrary.http.okhttp.MSPUtils;

public class MInfoManager {
    final static String SP_File_NANE = "share_file";
    final static String route_key = "route_key";
    private static volatile MInfo info;


    public static MInfo getMInfo() {
        if (info == null) {
            Object obj = MSPUtils.StrToObj(MSPUtils.getString(SP_File_NANE, route_key, null));
            if (obj instanceof MInfo) {
                info = (MInfo) obj;
            }
        }
        return info;
    }

    public static MInfo saveMInfo(MInfo info) {
        if (info == null)
            return MInfoManager.info;
        MSPUtils.put(SP_File_NANE, route_key, MSPUtils.ObjToStr(info));
        return MInfoManager.info = info;
    }

    //default
    public static List<Route> getDefaultRoutes() {
        List<Route> routes = new ArrayList<>();
        for(int i = 0; i< Constant.URLS.length; i++){
            Route route = new Route(Constant.URLS[i], "路线"+(i+1));
            routes.add(route);
        }
        return routes;
    }

}
